<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>二手房</title>
    <!-- Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<!--<nav class="navbar navbar-inverse" style=" height: 45px; margin: unset" th:fragment="top">-->
<nav class="navbar navbar-inverse navbar-static-top" style="margin-bottom: unset" th:fragment="top">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" data-toggle="collapse" data-target="#res-nav">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="/index" class="navbar-brand"><strong>Easily Living</strong></a>
    </div>
    <div class="collapse navbar-collapse" id="res-nav">
        <ul class="nav navbar-nav">
            <li><a href="#" th:href="@{/index}">首页</a></li>
            <li><a href="#" th:href="@{/house_list}">二手房</a></li>
            <li><a href="#" th:href="@{/estate_list}">楼盘</a></li>
            <li><a href="#" th:href="@{/agent_list}">经纪人</a></li>
            <li><a href="#" onclick="checkAgent()">发布房源</a></li>
            <script th:inline="javascript" >
                function checkAgent() {
                    var agent = '[[${session.agent}]]';
                    if(agent === 'null')
                        alert("权限不够，无法操作");
                    else window.location.href='/add_house_before';
                }
            </script>
        </ul>
        <div class="navbar-right">
            <P th:if="${session.agent eq null && session.user eq null}" class="navbar-text">
                <a href="/login_user" class="navbar-link" style="padding-right: 10px">登录</a>
                <a href="/signup" class="navbar-link">注册</a>
            </P>
            <P th:if="${session.agent != null}" class="navbar-text">您好，<a href="/user/center" class="navbar-link" th:text="${session.agent.agentName}"></a></P>
            <P th:if="${session.user != null}" class="navbar-text">您好，<a href="/user/center" class="navbar-link" th:text="${session.user.userName}"></a></P>
            <P th:unless="${session.agent eq null && session.user eq null}" class="navbar-text">
                <a href="/logout" style="font-size: smaller;" class="navbar-link">注销</a>
            </P>
        </div>
    </div>
    </div>
</nav>
</body>
</html>